package bookClass;

public class Book {
    private String bookNo;
    private String bookTitle;
    private String author;
    private int yearPublished;
    //构造方法
    public Book(String bookNo,String bookTitle,String author,int yearPublished)
    {
        this.bookNo = bookNo;
        this.bookTitle = bookTitle;
        this.author = author;
        this.yearPublished = yearPublished;
    }
    //显示书号
    public void showBookNo()
    {
        System.out.println("书号："+bookNo);
    }
    //显示书名
    public void showBookTitle()
    {
        System.out.println("书名："+bookTitle);
    }
    //显示作者
    public void showAuthor()
    {
        System.out.println("作者："+author);
    }
    //显示出版年份
    public void showYearPublished()
    {
        System.out.println("出版年份："+yearPublished);
    }
    //修改出版年份
    public void modifyYearPublished(int newYearPublished)
    {
        yearPublished = newYearPublished;
    }
    public static void main(String[] args)
    {
        Book b1 = new Book("ISBN123456789","Java Programming","John Doe",2024);
        Book b2 = new Book("ISBN987654321","Data Structures","Jane Smith",2023);
        //显示两本书的相关信息
        System.out.println("书籍信息：");
        System.out.println("书籍1：");
        b1.showBookNo();
        b1.showBookTitle();
        b1.showAuthor();
        b1.showYearPublished();
        System.out.println("书籍2：");
        b2.showBookNo();
        b2.showBookTitle();
        b2.showAuthor();
        b2.showYearPublished();
        //修改b1的出版年份
        b1.modifyYearPublished(2021);
        //显示修改后的结果
        System.out.println("修改后的书籍1信息：");
        b1.showBookNo();
        b1.showBookTitle();
        b1.showAuthor();
        b1.showYearPublished();
    }
}
